<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/web/header.jsp"%>
<link rel="stylesheet" type="text/css"
	href="/B2CMall/web/base/css/login.css">
<title>登录页面</title>
</head>
<body>

	<form class="form center" onsubmit="return false">
		<div class="login">
			<div class="login_center">
				<div class="login_top">
					<div class="left fl">会员登录</div>
					<div class="right fr">
						您还不是我们的会员？<a href="./reg.jsp" target="_self">立即注册</a>
					</div>
					<div class="clear"></div>
					<div class="xian center"></div>
				</div>
				<div class="login_main center">
					<div class="username">
						用户名:&nbsp;<input class="shurukuang" type="text" name="code"
							placeholder="请输入你的用户名" />
					</div>
					<div class="username">
						密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;<input class="shurukuang"
							type="password" name="pass" placeholder="请输入你的密码" />
					</div>
					<div class="username">
						<div class="left fl">
							验证码:&nbsp;<input class="yanzhengma" type="text" name="authcode"
								placeholder="请输入验证码" />
						</div>
						<div class="right fl">
							<img src="/B2CMall/AuthCodeController/auth.do"
								onclick='this.src="/B2CMall/AuthCodeController/auth.do?"+Math.random()'>
						</div>
						<div class="clear"></div>
					</div>
				</div>
				<div class="login_submit">
					<input class="submit" type="submit" name="submit" value="立即登录"
						onclick="login()">
				</div>
				<div class="regist_submit">
					<input class="submit" type="reset" name="reset" value="重置">
				</div>
			</div>
		</div>
	</form>

	<script type="text/javascript">
		function login() {
			var code = $("input[name='code']").val();
			var pass = $("input[name='pass']").val();
			var authcode = $("input[name='authcode']").val();
			ajax({
				code : code,
				pass : pass,
				authcode : authcode
			}, '/user/login.do', 'text', function(data) {
				if (data == "C") {
					layer.msg("登录成功", {
						time : 1000
					}, function() {
						toJsp("/web/front/index.jsp")
					});
				} else if (data == "B") {
					layer.msg("密码错误", {
						time : 1000
					}, function() {
						toJsp("/web/front/login.jsp")
					});
				} else if (data == "A") {
					layer.msg("帐号不存在", {
						time : 1000
					}, function() {
						toJsp("/web/front/login.jsp")
					});
				} else if (data == "F") {
					layer.msg("验证码错误", {
						time : 1000
					}, function() {
						toJsp("/web/front/login.jsp")
					});
				} else if (data == "S") {
					layer.msg("登录成功", {
						time : 1000
					}, function() {
						toJsp("/web/main.jsp")
					});
				}
			})
		}
	</script>
</body>
</html>